

***************************************************************
*******Firm Customer Income Distributions
clear all
use Figure_A7_Data

***Clean up the range a bit
drop if simplified_annualized_income==300000
drop if simplified_annualized_income<10000
keep if year==2014
drop if simplified==.

**Normalize by annual spending at a firm
egen total_spend = sum(spending_by_firm_income_group), by(gvkey firm_name year)
replace spending_by_firm_income_group = spending_by_firm_income_group/total_spend

label var spending_by_firm_income_group "Fraction of Sales"
label var simplified_annualized_income "Customers' Annual Income"

***This makes various customer base comparisions across firms (bar charts)
twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="WALMART INC", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="COSTCO WHOLESALE CORP", barwidth(2400) bcolor(blue) fcolor(none) legend(col(2) lab(1 "WALMART") lab(2 "COSTCO") region(fcolor(gs15))) )
graph export Output/bar_walmart_costco.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="DOLLAR GENERAL CORP"|firm=="DOLLAR TREE INC"|firm=="FAMILY DOLLAR STORES", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="REI", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "DOLLAR GENERAL") lab(2 "REI") region(fcolor(gs15))) )
graph export Output/bar_dollar_rei.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="PANDA RESTAURANT GROUP", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="P F CHANGS CHINA BISTRO INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "PANDA EXPRESS") lab(2 "PF CHANGS") region(fcolor(gs15))) )
graph export Output/bar_panda_pfchangs.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="99 CENTS ONLY STORES", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="WILLIAMS-SONOMA INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "GOODWILL") lab(2 "WILLIAMS-SONOMA") region(fcolor(gs15))) )
graph export Output/bar_goodwill_williams.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="JACK IN THE BOX INC", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="PANERA BREAD CO", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "JACK IN THE BOX") lab(2 "PANERA BREAD") region(fcolor(gs15))) )
graph export Output/bar_jack_panera.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="ROSS STORES INC", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="NORDSTROM INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "ROSS") lab(2 "NORDSTROMS") region(fcolor(gs15))) )
graph export Output/bar_ross_nordstrom.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="WAFFLE HOUSE", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="CORNER BAKERY", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "WAFFLE HOUSE") lab(2 "CORNER BAKERY") region(fcolor(gs15))) )
graph export Output/bar_waffle_cornerbake.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="GAMESTOP CORP", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="BARNES & NOBLE EDUCATION INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "GAMESTOP") lab(2 "BARNES AND NOBLE") region(fcolor(gs15))) )
graph export Output/bar_gamestop_barnes.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="SAVE-A-LOT INC -SPN", bcolor(red) fcolor(none) barwidth(2400))(bar spending_by_firm_income_group simplified_annualized_income if firm=="WHOLE FOODS MARKET INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "SAVE-A-LOT") lab(2 "WHOLE FOODS") region(fcolor(gs15))) )
graph export Output/bar_savealot_wholefoods.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="LA FITNESS", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="EQUINOX", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "LA FITNESS") lab(2 "EQUINOX") region(fcolor(gs15))) )
graph export Output/bar_lafitness_equinox.png, height(600) width(900) replace


***This makes some comparisons between firms with similar customer mean incomes but differential spreads


*FAMILY DOLLAR STORES	55421.94; 99 CENTS ONLY STORES	55915.65
twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="FAMILY DOLLAR STORES", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="99 CENTS ONLY STORES", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "FAMILY DOLLAR STORES") lab(2 "99 CENTS ONLY STORES") region(fcolor(gs15))) )
graph export Output/spread_familydollar_99cents.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="H-E-B GROCERY", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="ALBERTSONS COS INC  -REDH", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "H-E-B GROCERY") lab(2 "ALBERTSONS COS INC  -REDH") region(fcolor(gs15))) )
graph export Output/spread_heb_albertson.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="BLUE NILE INC", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="TIFFANY & CO", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "BLUE NILE INC") lab(2 "TIFFANY & CO") region(fcolor(gs15))) )
graph export Output/spread_tiffany_bluenile.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="SHAKE SHACK INC", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="P F CHANGS CHINA BISTRO INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "SHAKE SHACK INC") lab(2 "P F CHANGS CHINA BISTRO INC") region(fcolor(gs15))) )
graph export Output/spread_shakeshack_pfchang.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="DICKS SPORTING GOODS INC", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="URBAN OUTFITTERS INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "DICKS SPORTING GOODS INC") lab(2 "URBAN OUTFITTERS INC") region(fcolor(gs15))) )
graph export Output/spread_dicks_urban.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="SPIRIT AIRLINES INC", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="VIRGIN AMERICA INC", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "SPIRIT AIRLINES INC") lab(2 "VIRGIN AMERICA INC") region(fcolor(gs15))) )
graph export Output/spread_spirit_virgin.png, height(600) width(900) replace

twoway (bar spending_by_firm_income_group simplified_annualized_income if firm=="LIFE TIME FITNESS INC", bcolor(red) fcolor(none) barwidth(2400)) ///
(bar spending_by_firm_income_group simplified_annualized_income if firm=="EQUINOX", bcolor(blue) fcolor(none) barwidth(2400) legend(col(2) lab(1 "LIFE TIME FITNESS INC") lab(2 "EQUINOX") region(fcolor(gs15))) )
graph export Output/spread_lifetime_equinox.png, height(600) width(900) replace

